//
//  MoreInforViewController.m
//  美食百科
//
//  Created by dllo on 16/1/29.
//  Copyright © 2016年 doll. All rights reserved.
//

#import "MoreInforViewController.h"
#import "ContentTableViewCell.h"
@interface MoreInforViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,retain)UITableView *tableView;
@end

@implementation MoreInforViewController
- (void)dealloc
{
    [_tableView release];
    [_array release];
    [_titles release];
    [_gram release];
    [_calory release];
    [_protein release];
    [_fat release];
    [_carbohydrate release];
    [_fiber_dietary release];

    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   // self.view.backgroundColor = [UIColor whiteColor];
    UIBarButtonItem *leftItemFirst = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"iconfont-zuojiantou-3"] style:UIBarButtonItemStylePlain target:self action:@selector(backAction:)];
    
    UIBarButtonItem *leftItemSecond = [[UIBarButtonItem alloc]initWithTitle:@"营养信息" style:UIBarButtonItemStyleDone target:self action:nil];
    self.navigationItem.leftBarButtonItems = @[leftItemFirst,leftItemSecond];
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-64) style:UITableViewStylePlain];
    self.tableView.backgroundColor = [UIColor clearColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.bounces = NO;
    [self.view addSubview:self.tableView];
    [_tableView release];
    
    [self.tableView registerClass:[ContentTableViewCell class] forCellReuseIdentifier:@"content"];

}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ContentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"content"];
    cell.labelOne.text = self.titles[indexPath.row];
    cell.labelTwo.text =[NSString stringWithFormat:@"%@%@",self.array[indexPath.row], self.gram[indexPath.row]];
    if ([self.array[indexPath.row] isEqualToString:@""]) {
        cell.labelTwo.text = @"--";
    }
    if (indexPath.row == 0) {
        cell.labelThree.text = self.calory;
    }else if (indexPath.row == 1)
    {
        cell.labelThree.text = self.protein;
        
    }else if (indexPath.row == 2)
    {
        cell.labelThree.text = self.fat;
        
    }else if (indexPath.row == 3)
    {
        cell.labelThree.text = self.carbohydrate;
        
    }else if (indexPath.row == 4)
    {
        cell.labelThree.text = self.fiber_dietary;
        
    }else
    {
        cell.labelThree.text = @"";
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}
-(void)backAction:(UIBarButtonItem *)item{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
